From e248dc43ae6f8f4028f34bf8b3d01b83a59795f0 Mon Sep 17 00:00:00 2001 From: "emellor@ewan" Date: Tue, 11 Oct 2005 10:29:29 +0100 Subject: [PATCH] Added xsls utility, which recursively lists the contents of the store. Signed-off-by: Ewan Mellor --- .hgignore | 1 + tools/xenstore/Makefile | 6 +++++- tools/xenstore/xsls.c | 47 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 tools/xenstore/xsls.c diff --git a/.hgignore b/.hgignore index 72b8f826d7..a4e2a8ee32 100644 --- a/.hgignore +++ b/.hgignore @@ -161,6 +161,7 @@ ^tools/xenstore/xs_tdb_dump$ ^tools/xenstore/xs_test$ ^tools/xenstore/xs_watch_stress$ +^tools/xenstore/xsls$ ^tools/xentrace/xenctx$ ^tools/xentrace/xentrace$ ^xen/BLOG$ diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile index 212ae13e4a..5d29ad301a 100644 --- a/tools/xenstore/Makefile +++ b/tools/xenstore/Makefile @@ -27,7 +27,7 @@ CLIENTS := xenstore-exists xenstore-list xenstore-read xenstore-rm CLIENTS += xenstore-write CLIENTS_OBJS := $(patsubst xenstore-%,xenstore_%.o,$(CLIENTS)) -all: libxenstore.so xenstored $(CLIENTS) xs_tdb_dump +all: libxenstore.so xenstored $(CLIENTS) xs_tdb_dump xsls testcode: xs_test xenstored_test xs_random @@ -40,6 +40,9 @@ $(CLIENTS): xenstore-%: xenstore_%.o $(CLIENTS_OBJS): xenstore_%.o: xenstore_client.c $(COMPILE.c) -DCLIENT_$(*F) -o $@ $< +xsls: xsls.o + $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -lxenctrl -L. -lxenstore -o $@ + xenstored_test: xenstored_core_test.o xenstored_watch_test.o xenstored_domain_test.o xenstored_transaction_test.o xs_lib.o talloc_test.o fake_libxc.o utils.o tdb.o $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ @@ -134,6 +137,7 @@ install: libxenstore.so xenstored $(CLIENTS) $(INSTALL_DIR) -p $(DESTDIR)/usr/include $(INSTALL_PROG) xenstored $(DESTDIR)/usr/sbin $(INSTALL_PROG) $(CLIENTS) $(DESTDIR)/usr/bin + $(INSTALL_PROG) xsls $(DESTDIR)/usr/bin $(INSTALL_DIR) -p $(DESTDIR)/usr/$(LIBDIR) $(INSTALL_DATA) libxenstore.so $(DESTDIR)/usr/$(LIBDIR) $(INSTALL_DATA) xs.h $(DESTDIR)/usr/include diff --git a/tools/xenstore/xsls.c b/tools/xenstore/xsls.c new file mode 100644 index 0000000000..f8cf24536a --- /dev/null +++ b/tools/xenstore/xsls.c @@ -0,0 +1,47 @@ +#include +#include +#include +#include +#include + +void print_dir(struct xs_handle *h, char *path, int cur_depth) +{ + char **e; + char newpath[512], *val; + int num, i, len; + + e = xs_directory(h, NULL, path, &num); + if (e == NULL) + err(1, "xs_directory (%s)", path); + + for (i = 0; i (151 - strlen(e[i]))) + printf(" = \"%.*s...\"\n", 148 - strlen(e[i]), val); + else + printf(" = \"%s\"\n", val); + free(val); + print_dir(h, newpath, cur_depth+1); + } + free(e); +} + +int main(int argc, char *argv[]) +{ + struct xs_handle *xsh = xs_daemon_open(); + + if (xsh == NULL) + err(1, "xs_daemon_open"); + + print_dir(xsh, argc == 1 ? "/" : argv[1], 0); + + return 0; +} -- 2.30.2